import form from '../util/form.js'
const submit = {
	data() {
		return {
			disabled: false
		}
	},
	/**
	 * 提交表单之前，验证表单
	 * */
	onLoad() {
		const that = this;
		let oldSubmitForm = that.submitForm;
		that.submitForm = () => {
			let errMsg = form.validation(that.dataForm, that.rules);
			if (errMsg) {
				uni.showToast({
					icon: 'none',
					title: errMsg
				})
				return;
			}
			that.disabled = true;
			oldSubmitForm(() => {
				that.disabled = false
			});
		}
	}
}

export default submit;
